package com.autumn.cloud.demo.consumer.client;

import com.autumn.cloud.demo.common.model.UserInfo;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

/**
 * 用户信息熔断
 * <p>
 * </p>
 *
 * @description TODO
 * @author: 老码农
 * @create: 2020-12-11 02:17
 **/
// 必须注入
@Component
public class UserInfoFallbackFactory implements FallbackFactory<UserInfoFeignClient> {

    @Override
    public UserInfoFeignClient create(Throwable throwable) {
        return new UserInfoFeignClient() {

            @Override
            public UserInfo getUserInfo() {
                UserInfo userInfo = new UserInfo();
                userInfo.setMsg("Feign 熔断，服务器已断开，暂时无法访问");
                return userInfo;
            }
        };
    }
}
